import java.awt.*;
import java.awt.event.*;
 
public class Main implements ItemListener {
    Frame frame;
    Checkbox checkbox1, checkbox2, checkbox3;
     StringProcess sp=new StringProcess();	
//	String seperateString="[\\x01]";
	String seperateString="[\\p{Punct}]";


    public static void main(String[] args) {
        new Main();
    }
     
    public Main() {
	String tmpString="";

        frame = new Frame("AWTDemo");
        frame.addWindowListener(new AdapterDemo());
        frame.setLayout(new FlowLayout());
         
        checkbox1 = new Checkbox("c1");
        checkbox1.addItemListener(this);

        checkbox2 = new Checkbox("c2");
        checkbox2.setState(true);
        checkbox2.addItemListener(this);

        checkbox3 = new Checkbox("c3");
        checkbox3.addItemListener(this);
         
        frame.add(checkbox1);
tmpString=checkbox1.toString();//not use this cause index wrong?
        frame.add(checkbox2);
tmpString=checkbox2.toString();
        frame.add(checkbox3);
tmpString=checkbox3.toString();



        frame.pack();
        frame.setVisible(true);
         
 //       System.out.println("c1: " + checkbox1+"="+checkbox1.getState());
   //     System.out.println("c2: " + checkbox2+"="+checkbox2.getState());
     //   System.out.println("c3: " + checkbox3+"="+checkbox3.getState());

    }
     
    public void itemStateChanged(ItemEvent e) {
	String[] tmpString;


        Checkbox c = (Checkbox) e.getSource();
        String l = c.getLabel();

	tmpString=sp.getStringArray(c.toString(),seperateString,null);
	if(tmpString!=null){
		for(int i=0;i<tmpString.length;i++){
//			System.out.println(tmpString[i]);
		}
	}

        if (e.getStateChange() == ItemEvent.SELECTED) {
            c.setLabel("on");
            System.out.println(l + " selected");
            System.out.println(c);

        }
        else {
            System.out.println(l + " deselected");
            System.out.println(c);
			switch(tmpString[3]){
				case "checkbox0":
					c.setLabel("c1");
					break;
				case "checkbox1":
					c.setLabel("c2");
					break;
				case "checkbox2":
					c.setLabel("c3");
					break;
				default:
					break;
			}
        }
    }
}
 
class AdapterDemo extends WindowAdapter {
    public void windowClosing(WindowEvent e) {
        System.exit(0);
    }
}